// 获取所有列表项名称
var lb = document.querySelector('.lb')
var xhr = new XMLHttpRequest()
xhr.open('get','http://47.116.75.38:8101/web/team/experts/getDictInfo')
xhr.send(null)
xhr.onload = function () {
  var res = JSON.parse(xhr.response)
  res.data.forEach(function (itme) {
    var div = document.createElement('div')
    div.classList.add('lb-all')
    var i = document.createElement('i')
    i.className = 'iconfont icon-left-s i'
    var span = document.createElement('span')
    span.innerText = itme.dictLabel
    div.appendChild(i)
    div.appendChild(span)
    lb.appendChild(div)
    var ul = document.createElement('ul')
    ul.className = 'all-tow all-ul al'
    lb.appendChild(ul)

  })
  //获取所有展示列表
  var all = document.querySelectorAll('.all-ul')
  for(let i = 0; i < all.length; i++){
      fn(all[i])
  }


  //获取所有lb-all
  var lbAll = document.querySelectorAll('.lb-all')
  var alls = document.querySelectorAll('.al')
  var icon = document.querySelectorAll('.i')
  for(let i = 0; i < lbAll.length; i++){
      lbAll[i].onclick = function () {
        alls[i].classList.toggle('allll')
        icon[i].classList.toggle('icon')
      }
  }
}

var allOne = document.querySelector('.all-one')
fn(allOne)
function fn(name){
//获取全部列表
  var xhr1 = new XMLHttpRequest()
  xhr1.open('post','http://47.116.75.38:8101/web/team/experts/list')
  xhr1.setRequestHeader('Content-Type','application/json;charset=UTF-8')
  xhr1.send(
      JSON.stringify({
        "current": 1,
        "size": 10,
        "params": {
          "userId": "",
          "areaId": "",
          "teamId": ""
        },
        "orderBy": ""
      })
  )
  xhr1.onload = function () {
    var res = JSON.parse(xhr1.response)
    res.data.records.forEach(function (item,index) {
      var li = document.createElement('li')
      li.classList.add('all-li')
      var span = document.createElement('span')
      var em = document.createElement('em')
      em.innerText = item.specialistName
      var i = document.createElement('i')
      i.innerText = item.nationality + '专家'
      span.appendChild(em)
      span.appendChild(i)
      var img = document.createElement('img')
      img.src = item.headPicture
      var p = document.createElement('p')
      p.innerText = item.introduce
      li.appendChild(span)
      li.appendChild(img)
      li.appendChild(p)
      name.appendChild(li)
    })
  }
}


var fh = document.querySelector('.fh')
document.onscroll = function () {
  if (document.documentElement.scrollTop > 1000){
    fh.style.display = 'block'
  }
  if (document.documentElement.scrollTop < 900){
    fh.style.display = 'none'
  }
}

fh.onclick = function () {
  document.documentElement.scrollTop = 0
  fh.style.display = 'none'
}


